package com.iretailer.report.quartz.horizon.wsSubscribe;

import com.iretailer.report.init.annotation.BootLoading;
import com.iretailer.report.init.annotation.ExecutionMethod;
import com.iretailer.report.quartz.horizon.Settings;
import com.iretailer.report.quartz.horizon.common.Signer;
import org.java_websocket.client.WebSocketClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;

/**
 * @Auther: xjw
 * @Date: 2019/10/18 0018 10:33
 * @Description:
 */
//@BootLoading
@Component
public class BootLoadingWsClinet {

    @Autowired
    private ExecutorService threadPool;

    //    @ExecutionMethod
    public void start() {
        threadPool.execute(() -> {
            Signer signer = new Signer(Settings.AK, Settings.SK);
            SubscribeImp subscribeImp = new SubscribeImp(signer, Settings.PAAS_HOST, Settings.WEBSOCKET_HOST, "device", "0694E001020110625L");
            WebSocketClient client = subscribeImp.getWebSocketClient();
            if (client != null) {
                client.connect();
            }
        });
    }
}
